package cn.elwy.rcp.ui.dialog;

import java.io.Serializable;

import org.eclipse.jface.dialogs.DialogSettings;
import org.eclipse.jface.dialogs.IDialogSettings;

import cn.elwy.common.util.ConvertTypeUtil;

public class CustomeSettings extends DialogSettings implements Serializable {

  private static final long serialVersionUID = 1L;

  public CustomeSettings(String sectionName) {
    super(sectionName);
  }

  /*
   * (non-Javadoc) Method declared on IDialogSettings.
   */
  public IDialogSettings addNewSection(String sectionName) {
    CustomeSettings section = new CustomeSettings(sectionName);
    addSection(section);
    return section;
  }

  /*
   * (non-Javadoc) Method declared on IDialogSettings.
   */
  public boolean getBoolean(String key) {
    return ConvertTypeUtil.toBoolean(get(key));
  }

  /*
   * (non-Javadoc) Method declared on IDialogSettings.
   */
  public double getDouble(String key) throws NumberFormatException {
    return (Double) ConvertTypeUtil.toNumber(get(key), 0.0d);
  }

  /*
   * (non-Javadoc) Method declared on IDialogSettings.
   */
  public float getFloat(String key) throws NumberFormatException {
    return (Float) ConvertTypeUtil.toNumber(get(key), 0.0f);
  }

  /*
   * (non-Javadoc) Method declared on IDialogSettings.
   */
  public int getInt(String key) throws NumberFormatException {
    return ConvertTypeUtil.toInteger(get(key));
  }

  /*
   * (non-Javadoc) Method declared on IDialogSettings.
   */
  public long getLong(String key) {
    return (Long) ConvertTypeUtil.toNumber(get(key), 0l);
  }

}
